iconhelper: Move invalidation check
authorBenjamin Otte <otte@redhat.com>
Sun, 29 Nov 2015 18:45:52 +0000 (19:45 +0100)
committerBenjamin Otte <otte@redhat.com>
Tue, 1 Dec 2015 23:29:29 +0000 (00:29 +0100)
Just do the invalidation check once, there's no need to do it in every
branch of the switch.

Also remove useless checks: These functions will not be called if we
already have a rendered surface.

gtk/gtkiconhelper.c

index 4f222ad77b0cbc5e374f67a4e78fd8d7fb8c01c0..fff19612b69a1a1b901aa5d8716a76a404f2ff83 100644 (file)
@@ -546,12 +546,6 @@ ensure_surface_from_surface (GtkIconHelper   *self,
                             GtkStyleContext *context,
                              cairo_surface_t *orig_surface)
 {
-  if (!check_invalidate_surface (self, context))
-    return;
-
-  if (self->priv->rendered_surface)
-    return;
-
   self->priv->rendered_surface =
     cairo_surface_reference (orig_surface);
 
@@ -622,12 +616,6 @@ ensure_surface_from_pixbuf (GtkIconHelper   *self,
   GdkPixbuf *pixbuf, *stated;
   int scale;
 
-  if (!check_invalidate_surface (self, context))
-    return;
-
-  if (self->priv->rendered_surface)
-    return;
-
   if (get_pixbuf_size (self,
                        context,
                        orig_pixbuf,
@@ -657,9 +645,6 @@ ensure_surface_for_icon_set (GtkIconHelper *self,
 {
   gint scale;
 
-  if (!check_invalidate_surface (self, context))
-    return;
-
   scale = get_scale_factor (self, context);
 
   G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
@@ -741,9 +726,6 @@ ensure_surface_for_gicon (GtkIconHelper   *self,
   GtkIconInfo *info;
   GtkIconLookupFlags flags;
 
-  if (!check_invalidate_surface (self, context))
-    return;
-
   icon_theme = gtk_icon_theme_get_for_screen (gtk_style_context_get_screen (context));
   flags = get_icon_lookup_flags (self, context);
 
@@ -769,6 +751,9 @@ _gtk_icon_helper_ensure_surface (GtkIconHelper *self,
   GtkIconSet *icon_set;
   GIcon *gicon;
 
+  if (!check_invalidate_surface (self, context))
+    return self->priv->rendered_surface;
+
   switch (gtk_image_definition_get_storage_type (self->priv->def))
     {
     case GTK_IMAGE_SURFACE: